﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class AttrAttrgroupRelationEntityTypeConfiguration : IEntityTypeConfiguration<AttrAttrgroupRelation>
    {
        public void Configure(EntityTypeBuilder<AttrAttrgroupRelation> builder)
        {
            // 不使用output子句
            builder.ToTable(table=>table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(AttrAttrgroupRelation))
                .ToTable(tableBuilder => tableBuilder.HasComment("属性&属性分组关联"));

            builder
                .HasKey(attrAttrgroupRelation => attrAttrgroupRelation.AttrAttrgroupRelationID)
                .HasName("AttrAttrgroupRelationID");

            builder
                .Property(attrAttrgroupRelation => attrAttrgroupRelation.AttrID)
                .HasColumnName("AttrID")
                .HasColumnType("int")
                .HasComment("属性id")
                .IsRequired(true);

            builder
                .Property(attrAttrgroupRelation => attrAttrgroupRelation.AttrGroupID)
                .HasColumnName("AttrGroupID")
                .HasColumnType("int")
                .HasComment("属性分组id")
                .IsRequired(true);

            builder
                .Property(attrAttrgroupRelation => attrAttrgroupRelation.AttrSort)
                .HasColumnName("AttrSort")
                .HasColumnType("int")
                .HasComment("属性组内排序")
                .IsRequired(false);

            builder
                .Property(attrAttrgroupRelation => attrAttrgroupRelation.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(attrAttrgroupRelation => attrAttrgroupRelation.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
